'use strict';

const Controller = require('../lib/controller');

class UploadController extends Controller {
  async index() {

    // Main Layout -------------------------------------------------------------
    if (theUser.rights['upload'] < 1 || theCache.settings['enableUpload'] != 1) {
      write(lang['no_rights']);
      Response.End;
    }
  }

  // Check File Type
  isValidType(str) {
    var list = theCache.settings['uploadTypes'].toLowerCase().split(',');
    str = str.toLowerCase();
    for (var i = 0; i < list.length; i++) {
      if (str == list[i]) return true;
    }
    return false;
  }

  // Clean up File Name
  cleanFileName(str) {
    str = str.replace(/[^_\.a-zA-Z\d]/ig, '');
    str = str.replace(/^[\/\.]+/, '');
    return str;
  }

  //Upload File - I have to use VBScript to call the Upload Class
  doUpload(uploadPath, uploadSize) {

  }
}
